import { defHttp } from "/@/utils/http/axios"
import { Modal } from "ant-design-vue"

export const listIdpConnectApp = (params: any) => {
  return defHttp.get({ url: "/iam-service/extIdpConnect/listConnectApp", params })
}

export const updateIdpConnectApp = (params: any) => {
  return defHttp.post({ url: "/iam-service/extIdpConnect/updateConnectApp", params })
}


export const deleteIdpConnect = (params: any) => {
  return defHttp.delete({ url: "/iam-service/extIdpConnect/delete", data: params }, { joinParamsToUrl: true})
}

export const countIdpConnect = (params) => {
  return defHttp.get({ url: "/iam-service/extIdpConnect/count", params })
}

export const listIdpConnect = (params) => {
  return defHttp.get({ url: "/iam-service/extIdpConnect/list", params })
}

export const saveIdpConnect = (params, isUpdate) => {
  const url = isUpdate ? "/iam-service/extIdpConnect/update" : "/iam-service/extIdpConnect/save"
  return defHttp.post({ url: url, params })
}

export const getIdp = (params) => {
  return defHttp.get({ url: "/iam-service/extIdp/get", params })
}

export const saveIdp = (params) => {
  return defHttp.post({ url: "/iam-service/extIdp/save", params })
}

export const deleteIdp = (params) => {
  return defHttp.delete({ url: "/iam-service/extIdp/delete", data: params }, { joinParamsToUrl: true})
}

export const listIdp = (params) => {
  return defHttp.get({ url: "/iam-service/extIdp/list", params })
}


export const saveIdpConnectTmpl = (params, isUpdate) => {
  const url = isUpdate ? "/iam-service/extIdpConnectTmpl/update" : "/iam-service/extIdpConnectTmpl/save"
  return defHttp.post({ url: url, params })
}

export const deleteIdpConnectTmpl = (params, handleSuccess) => {
  return defHttp.delete({ url: "/iam-service/extIdpConnectTmpl/delete", data: params }, { joinParamsToUrl: true }).then(() => {
    handleSuccess()
  })
}

/**
 * 获取拷贝数据
 * @param params 
 * @returns 
 */
export const getCopyIdpTmpl = (params) => {
  return defHttp.get({ url: "/iam-service/extIdpTmpl/copy", params })
}

export const importIdpTmpl = (params) => {
  return defHttp.post({ url: "/iam-service/extIdpTmpl/import", params })
}


export const pageIdpTmpl = (params) => {
  return defHttp.get({ url: "/iam-service/extIdpTmpl/page", params })
}

export const listIdpTemplate = (params) => {
  return defHttp.get({ url: "/iam-service/extIdpTmpl/list", params })
}

export const saveOrUpdateIdpTmpl = (params, isUpdate) => {
  const url = isUpdate ? "/iam-service/extIdpTmpl/update" : "/iam-service/extIdpTmpl/save"
  return defHttp.post({ url: url, params })
}

export const getIdpTmpl = (params) => {
  return defHttp.get({ url: "/iam-service/extIdpTmpl/get", params })
}

export const deleteIdpTmpl = (params, handleSuccess) => {
  return defHttp.delete({ url: "/iam-service/extIdpTmpl/delete", data: params }, { joinParamsToUrl: true }).then(() => {
    handleSuccess()
  })
}

export const batchDeleteIdpTmpl = (params, handleSuccess) => {
  Modal.confirm({
    title: "确认删除",
    content: "是否删除选中数据",
    okText: "确认",
    cancelText: "取消",
    onOk: () => {
      return defHttp.delete({ url: "/iam-service/extIdpTmpl/deleteBatch", data: params }, { joinParamsToUrl: true }).then(() => {
        handleSuccess()
      })
    },
  })
}
